import 'package:flutter/material.dart';

const cityNames = [
  '北京','南京','杭州','上海','深圳','广州','合肥','太原','济南','南昌','乌鲁木齐','沈阳','哈尔滨','长春'
];

class VerticalListPage extends StatefulWidget {
  const VerticalListPage({super.key});

  @override
  State<VerticalListPage> createState() => _VerticalListPageState();
}

class _VerticalListPageState extends State<VerticalListPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('下拉刷新数据')),
      body: ListView(
        children: _buildList(),
      ),
    );
  }

  List<Widget> _buildList() {
    return cityNames.map((city) => _item(city)).toList();
  }
  Widget _item(String city) {
    return Container(
      height: 80, margin: const EdgeInsets.only(bottom: 5),alignment: Alignment.center,
      decoration: const BoxDecoration(color: Colors.amber),
      child: Text(city,style: TextStyle(color: Colors.white, fontSize: 20),),
    );
  }
}
